package ObserverPattern;


import Filter.AbstractSource;
import Filter.Source;
import Proxy.MyFile;
import Proxy.FileInterface;
import java.util.ArrayList;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Andreea
 */
public class FileCollection implements Subject{
    private ArrayList<FileInterface> files;
    private AbstractSource source=new Source();

    public FileCollection() {
        files=new ArrayList<FileInterface>();
        files=source.getData(files, null);
    }

    public ArrayList<FileInterface> getFiles() {
        return files;
    }

    public void setFiles(ArrayList<FileInterface> files) {
        this.files = files;
    }
    public void clearCollection(){
        this.files.clear();
    }
    public void addFile(MyFile f){
        this.files.add(f);
    }
    public void removeFile(MyFile f){
        this.files.remove(f);
    }
    
    @Override
    public String toString() {
        return "FileCollection{" + "files=" + files + '}';
    }

    @Override
    public void notifyObserver() {
        for(Observer o:observers)
            o.notify();
    }

    @Override
    public void addObserver(Observer o) {
        observers.add(o);
    }

    @Override
    public void removeObserver(Observer o) {
        observers.remove(o);
    }
    
}
